package woshiheima4;

import java.util.Arrays;
/*冒泡排序*/
public class ArryDemo {
    public static void main(String[] args) {
        int[] arr = {12, 8, 65, 45};
        String arrString = Arrays.toString(arr);
        System.out.print("排序前:" + arrString);

        //第一次比较
        for (int x = 0; x < arr.length-1; x++) {
            for (int i = 0; i < arr.length - 1 - x; i++) {
                if (arr[i] < arr[i + 1]) {
                    int temp = arr[i];//交换位置
                    arr[i] = arr[i + 1];
                    arr[i + 1] = temp;
                }
            }
            System.out.print("第一次比较后:" + arrString);


        }
    }
}
